/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package AuxClasses;

import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Marvin
 */
public class AddTransaccion {
    /*private String tipo;
    private String descripcion;
    private String valor;
    private String dpi;
    private String s;*/
    public AddTransaccion(String tipo, String descripcion, String valor, String dpi, Statement s)
    {
        try {
            Calendar calendar = Calendar.getInstance();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
            String query = "INSERT INTO `bancofarmville`.`transaccion` (`fecha`, `descripcion`, `tipo`, `valor`, `Usuario_DPI`) VALUES (";
            query = query + "\""+dateFormat.format(calendar.getTime())+"\",";
            query = query + "\""+descripcion+"\",";
            query = query + "\""+tipo+"\",";
            query = query + "\""+valor+"\",";
            query = query + "\""+dpi+"\");";
            s.execute(query);
        } catch (Exception ex) {
            Logger.getLogger(AddTransaccion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public AddTransaccion(String tipo, String descripcion, String valor, String dpi, Statement s, String cuotas)
    {
        try {
            Calendar calendar = Calendar.getInstance();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
            String query = "INSERT INTO `bancofarmville`.`transaccion` (`fecha`, `descripcion`, `tipo`, `valor`, `Usuario_DPI`) VALUES (";
            query = query + "\""+dateFormat.format(calendar.getTime())+"\",";
            query = query + "\""+descripcion+"\",";
            query = query + "\""+tipo+"\",";
            query = query + "\""+valor+"\",";
            query = query + "\""+dpi+"\");";
            s.execute(query);
            
            query = "INSERT INTO `bancofarmville`.`prestamo` (`Usuario_DPI`, `fecha_ini`, `monto`, `cuotas_total`, `cuotas_pendiente`) VALUES (";
            query = query + "\""+dpi+"\",";
            query = query + "\""+dateFormat.format(calendar.getTime())+"\",";
            query = query + "\""+valor+"\",";
            query = query + "\""+cuotas+"\",";
            query = query + "\""+cuotas+"\")";
            s.execute(query);
            
        } catch (Exception ex) {
            Logger.getLogger(AddTransaccion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
    /*public void Add()
    {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
        String query = "INSERT INTO `bancofarmville`.`transaccion` (`fecha`, `descripcion`, `tipo`, `valor`, `Usuario_DPI`) VALUES (";
        query = query + "\""+dateFormat.format(calendar.getTime())+"\",";
        query = query + "\""+descripcion+"\",";
        query = query + "\""+tipo+"\",";
        query = query + "\""+valor+"\",";
        query = query + "\""+dpi+"\");";
        
    }*/
}
